<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>案例表单</title>
<script type="text/javascript"
	src='<c:url value="/js/boot.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script src='<c:url value="/js/rqfui/rqfui.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style type="text/css">
body {
	height: 100%;
}

.fieldTitle {
	width: 80px !important;
}

.mini-tabs-leftButton, .mini-tabs-rightButton {
	display: none;
}

.mini-tabs-scrollCt {
	border-top: 0;
}

.mini-tabs-bodys {
	padding: 0;
}
.headerpan{
	margin-left: 10px;
	font-size: 14px;
	font-weight:bold;
}
</style>
<script type="text/javascript">
	var class1Data = [{'text':'突发'},{'text':'非突发'}];
	var class2Data = [{'text':'领事保护'},{'text':'领事协助'}];
	var class3Data = [{'text':'政局动荡'},{'text':'恐怖袭击'},{'text':'社会治安'},
	                  {'text':'自然灾害'},{'text':'意外事故'},{'text':'劳务纠纷'},
	                  {'text':'其他'}];
	var halfDayData = [{'text':'上午'},{'text':'下午'}]
	var purposeData = [{'text':'旅游'},{'text':'务工'},{'text':'留学'},
	                  {'text':'科技交流'},{'text':'会议'},{'text':'商贸谈判'},
	                  {'text':'其他'}];
	var injuredData = [{'id':0,'text':'无'},{'id':1,'text':'10人以下'},{'id':20,'text':'10-50人'},
	                   {'id':60,'text':'50-100人'},{'id':110,'text':'100人以上'}];
	var deathData = [{'id':0,'text':'无'},{'id':1,'text':'10人以下'},
	                 {'id':20,'text':'10-30人'},  {'id':40,'text':'30人以上'}];
</script>
</head>
<body>
	<form id="dataForm">
		<div class="formContent">
			<table class="formContentTable">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">案例名称</td>
					<td class="fieldContent" colspan="3"><input id="name"
						required="true" name="name" class="mini-textbox"
						style="width: 100%;" value="${name}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">案例类型</td>
					<td class="fieldContent" colspan="3"><input id="class1"
						required="true" name="class1" class="mini-combobox"
						style="width: 32%;" value="${class1}" textField="text"
						valueField="text" data="class1Data" />&nbsp;&nbsp;<input
						name="class2" required="true" class="mini-combobox"
						style="width: 32%;" textField="text" valueField="text"
						data="class2Data" showNullItem="false" allowInput="false" />&nbsp;&nbsp;<input
						name="class3" required="true" class="mini-combobox"
						style="width: 32%;" textField="text" valueField="text"
						data="class3Data" showNullItem="false" allowInput="false" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">案例内容</td>
					<td class="fieldContent" colspan="3"><textarea id="content"
							name="content" style="width: 100%; height: 150px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${content}"></textarea></td>
				</tr>
			</table>
			<br /> <span class="headerpan">基本信息</span>
			<table class="formContentTable">
				<tr>
					<td class="fieldTitle">时间</td>
					<td class="fieldContent"><input id="time" name="time"
						class="mini-datepicker" style="width: 100%;" value="${time}" /></td>
					<td class="fieldTitle">国家/地区</td>
					<td class="fieldContent"><input name="country_area"
						required="false" class="mini-combobox" style="width: 100%;"
						textField="zh_name" valueField="zh_name"
						url="<c:url value='/common/country'></c:url>" showNullItem="false"
						allowInput="true" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">辖区</td>
					<td class="fieldContent"><input id="area_range" name="area_range"
						class="mini-textbox" style="width: 100%;" value="${area_range}" /></td>
					<td class="fieldTitle">涉事人数</td>
					<td class="fieldContent"><input id="involved_num"
						name="involved_num" class="mini-textbox"
						style="width: 100%;" value="${involved_num}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">男性人数</td>
					<td class="fieldContent"><input id="male_num"
						name="male_num" class="mini-textbox"
						style="width: 100%;" value="${male_num}" /></td>
					<td class="fieldTitle">女性人数</td>
					<td class="fieldContent"><input id="female_num"
						name="female_num" class="mini-textbox"
						style="width: 100%;" value="${female_num}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">主要涉事人</td>
					<td class="fieldContent"><input id="involved_name"
						name="involved_name" class="mini-textbox" style="width: 100%;"
						value="${involved_name}" /></td>
					<td class="fieldTitle">年龄</td>
					<td class="fieldContent"><input id="involved_age"
						name="involved_age" class="mini-textbox"
						style="width: 100%;" value="${involved_age}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">出境目的</td>
					<td class="fieldContent"><input id="exit_purpose"
						required="false" name="exit_purpose" class="mini-combobox"
						style="width: 100%;" value="${exit_purpose}" textField="text"
						valueField="text" data="purposeData" /></td>
					<td class="fieldTitle">办理出国手续方式</td>
					<td class="fieldContent"><input id="way_abroad"
						name="way_abroad" class="mini-textbox" style="width: 100%;"
						value="${way_abroad}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">职业类别</td>
					<td class="fieldContent"><input id="vacation_class"
						name="vacation_class" class="mini-textbox" style="width: 100%;"
						value="${vacation_class}" /></td>
					<td class="fieldTitle">工作单位</td>
					<td class="fieldContent"><input id="work_place"
						name="work_place" class="mini-textbox" style="width: 100%;"
						value="${work_place}" /></td>
				</tr>
			</table>
			<br /> <span class="headerpan">案例详细</span>
			<table class="formContentTable">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">事情发生经过</td>
					<td class="fieldContent" colspan="3"><textarea id="event_occurs"
							name="event_occurs" style="width: 100%; height: 150px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${event_occurs}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">造成后果</td>
					<td class="fieldContent" colspan="3"><textarea id="results"
							name="results" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${results}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">受伤人数</td>
					<td class="fieldContent"><input id="injured_num"
						name="injured_num" class="mini-textbox"
						style="width: 100%;" value="${injured_num}" vtype="int"/></td>
					<%-- <td class="fieldContent"><input id="injured_num"
						required="false" name="injured_num" class="mini-combobox"
						style="width: 100%;" value="${injured_num}" textField="text"
						valueField="id" data="injuredData" /></td> --%>
					<td class="fieldTitle">死亡人数</td>
					<td class="fieldContent"><input id="death_num"
						name="death_num" class="mini-textbox"
						style="width: 100%;" value="${death_num}" vtype="int"/></td>
					<%-- <td class="fieldContent"><input id="death_num"
						required="false" name="death_num" class="mini-combobox"
						style="width: 100%;" value="${death_num}" textField="text"
						valueField="id" data="deathData" /></td> --%>
				</tr>
				<tr>
					<td class="fieldTitle">财务损失</td>
					<td class="fieldContent" colspan="3"><input id="finance_loss"
						name="finance_loss" class="mini-textbox" style="width: 100%;"
						value="${finance_loss}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">事件主要原因</td>
					<td class="fieldContent" colspan="3"><textarea id="cause"
							name="cause" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${cause}"></textarea></td>
				</tr>
			</table>
			<br /> <span class="headerpan">案例分析</span>
			<table class="formContentTable">
				<tr>
					<td class="fieldTitle">案例处理流程</td>
					<td class="fieldContent" colspan="3"><textarea id="handle_pro"
							name="handle_pro" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${handle_pro}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">案例分析</td>
					<td class="fieldContent" colspan="3"><textarea id="analysis"
							name="analysis" style="width: 100%; height: 150px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${analysis}"></textarea></td>
				</tr>
			</table>
			<br />
			<table class="formContentTable">
				<tr>
					<td class="fieldTitle">编制人</td>
					<td class="fieldContent"><input id="creater" enabled="false"
						name="creater" class="mini-textbox" style="width: 100%;"
						value="${creater}" /></td>
					<td class="fieldTitle">编制日期</td>
					<td class="fieldContent"><input id="createTime" enabled="false"
						name="createTime" class="mini-datepicker" style="width: 100%;"
						value="${createTime}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">信息来源</td>
					<td class="fieldContent" colspan="3"><input id="inforSource"
						name="inforSource" class="mini-textbox" style="width: 100%;"
						value="${inforSource}" /></td>
				</tr>
			</table>
		</div>
	</form>

	<script type="text/javascript">
		var rootPath = parent.getRootPath();
		var userName = parent.getUserName();
		var action = parent.getAction();
		var id = parent.getId();

		var dataOri = null;

		mini.parse();
		mini_debugger = false;
		var form = new mini.Form("dataForm");

		SetFormData();

		function SetFormData() {
			if (action == "new") {
				var o = new Object();
				o.creater = userName;
				o.createTime = new Date();
				form.setData(o);
				dataOri = o;
				return;
			}
			var messageid = mini.loading("获取中...", "Loading");
			var urlBase = '<c:url value="/case/form/"></c:url>' + id;
			$.ajax({
				url : urlBase,
				type : "get",
				dataType : 'json',
				success : function(text) {
					if (!text) {
						return;
					}
					var o = mini.decode(text);
					form.setData(o);
					dataOri = o;
					parent.labelModel(form);
				},
				complete : function(XMLHttpRequest, textStatus) {
					mini.hideMessageBox(messageid);
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
		function packData() {
			return form;
		}

		/* SetFormData();
		loadList();
		loadAttachment();
		parent.hideAttchPan(); */

		/* 加载附件 */
		function loadAttachment() {
			/* grid2.load(rootPath + "attchment/list/" + refNo + "/HTG/" + version);
			grid2.load();
			grid3.load(rootPath + "attchment/list/" + refNo + "/YY/" + version);
			grid3.load(); */

			grid2.load(rootPath + "attchment/listall/" + refNo + "/HTG");
			grid2.load({}, function() {
				if (grid2.data.length > 0) {
					grid2.groupBy("VersionGroup", "desc");
				}
			});
			grid3.load(rootPath + "attchment/listall/" + refNo + "/YY");
			grid3.load({}, function() {
				if (grid3.data.length > 0) {
					grid3.groupBy("VersionGroup", "desc");
				}
			});
		}

		function loadList() {
			if (version == null || version == "") {
				parent.mini.alert("无法获得数据版本!");
				return;
			}
			var url = '<c:url value="/wsData/ws000011/list/string/"></c:url>'
					+ refNo + "/" + version;
			grid1.load(url);
			grid1.load({}, function() {
				parent.contentFormOnload();
			});
		}

		function onDrawCell(e) {
			var item = e.record, field = e.field, value = e.value;
			if (field == "AttchmntName") {
				var html = "";
				var fileName = e.row.AttchmntName;
				var dotPos = fileName.lastIndexOf(".");
				if (dotPos > 0) {
					var fileType = fileName.substring(dotPos, fileName.length);
					if (typeof fileType != "undefined" && fileType != null) {
						fileType = fileType.toLowerCase();
					}
					switch (fileType) {
					case ".doc":
						html = "<span class='fileIcons docIcon'></span>";
						break;
					case ".docx":
						html = "<span class='fileIcons docxIcon'></span>";
						break;
					case ".xls":
						html = "<span class='fileIcons xlsIcon'></span>";
						break;
					case ".xlsx":
						html = "<span class='fileIcons xlsxIcon'></span>";
						break;
					case ".pdf":
						html = "<span class='fileIcons pdfIcon'></span>";
						break;
					case ".jpeg":
						html = "<span class='fileIcons jpegIcon'></span>";
						break;
					case ".jpg":
						html = "<span class='fileIcons jpgIcon'></span>";
						break;
					case ".bmp":
						html = "<span class='fileIcons bmpIcon'></span>";
						break;
					case ".png":
						html = "<span class='fileIcons pngIcon'></span>";
						break;
					case ".rar":
						html = "<span class='fileIcons rarIcon'></span>";
						break;
					default:
						html = "<span class='fileIcons normalIcon'></span>";
						break;
					}
				}
				var url = "<c:url value='/attchment/get/' />" + e.row.Id;
				e.cellHtml = html + "<a target='_blank' href='"+url+"'>"
						+ e.row.AttchmntName + "</a>";
			}
		}
		function setProjectLink(refNo, version) {
			$
					.ajax({
						url : "<c:url value='/webpart/path/w20' />",
						type : "get",
						dataType : 'html',
						success : function(text) {
							var htmlStr = "<a class='aTagUnderLine' href='" + text
						+"/" + refNo +"/" + version 
						+ "' target='_blank' >[查看项目相关信息]</a>";
							parent.setProjectLink(htmlStr);
						},
						complete : function(XMLHttpRequest, textStatus) {
						},
						error : function(XMLHttpRequest, textStatus,
								errorThrown) {
						}
					});
		}
		function onDrawGroup(e) {
			var groupId = e.group.id;
			var str = "版本：" + e.value;
			if (groupId == 'g1') {
				str += '（当前最新版本）';
			}
			e.cellHtml = str;
		}
	</script>
</body>
</html>